GM.Name 	= "G-Link"
GM.Author 	= ""
GM.Email 	= ""
GM.Website 	= ""

-- Variables you can change
-- Variables you shouldn't change
MAX_DIFFICULTY = 16

MIN_PASSWORD_LENGTH = 6
MAX_PASSWORD_LENGTH = 32

PASSWORD_LEEWAY_PERCENTILE = 0.3 -- Password can have this much leeway in length

PASSWORD_CHARS = {33,126}

ORG_MIN_DECEN = 8 -- The minimum difficulty level a corporation has to be before it can become a decentralized system.
ORG_MAX_CEN = 14 -- The maximum difficulty a level a corporation can be a centralized system at.
ORG_EMPS_PER_SEC = {3,6} -- For every level of security a particular server has, add more employees between this min and max.
ORG_FILES_PER_SEC = {1,6} -- For every level of security a particular server has, add more files between this min and max.

ORG_SERVER_SECURITY_RANGE_DEC = 0.3 -- The security of a decentralized organization's servers can vary this much from its difficulty.
ORG_SERVER_SECURITY_RANGE_CEN = 0.1 -- Same as above, but for centralized organizations.

-- Util functions
-- From http://www.ajdesigner.com/phpinterpolation/linear_interpolation_equation.php
function math.Interpolate(min,max,minv,maxv,int)
	return ((int-min)*(maxv-minv)/(max-min)) + minv
end

function math.sRandom(mi,ma) -- Seeded random. Generates a new seed every time it is called.
	if not mi then mi,ma = 0,1 end
	if not ma then ma=mi mi=1 end
	
	math.randomseed(CurTime()+SysTime()+math.sin(RealTime()*math.pi)+math.random(-5000,5000))
	
	return math.random(mi,ma)
end

function table.Random(t)
	local keys = {}
	for k,v in pairs(t) do
		table.insert(keys,k)
	end
	
	return t[keys[math.sRandom(#keys)]]
end

function string.Capitalize(str)
	return string.upper(string.sub(str,1,1))..string.lower(string.sub(str,2,string.len(str)))
end

function math.RoundToNearest(num,nearest)
	-- Adapted from http://www.refactory.org/s/rounding_a_number_to_the_nearest_ten_in_c/view/latest
	return math.floor((num+(nearest*0.5))/nearest)*nearest
end